#include <bits/stdc++.h>
using namespace std;
int main() {
    map<int, int> mp;
    int n;
    cin >> n;
    for (int i = 1, u, v; i <= n; ++i) {
        cin >> u >> v;
        mp[u] = v, mp[v] = u;
    }
    set<int> st, ans;
    cin >> n;
    for (int i = 1, x; i <= n; ++i) {
        cin >> x;
        st.insert(x);
    }
    for (int x : st) {
        if (!(st.count(x) && mp.count(x) && st.count(mp[x]))) {
            ans.insert(x);
        }
    }
    n = ans.size();
    cout << n << '\n';
    for (int x : ans) {
        --n;
        printf("%05d", x);
        if (n)
            cout << ' ';
        else
            cout << '\n';
    }
}